package com.fxkj.cloud.drms.domain.device.repository;

import com.fxkj.cloud.dbs.common.constants.DeviceStatusEnum;
import lombok.Getter;

import java.util.UUID;

/**
 * <p>description: </p>
 * @author ww
 * @date 2025/4/9 17:06
 */
@Getter
public class DeviceStatus {
    private long ts;
    private DeviceStatusEnum status;
    private UUID deviceId;
    private UUID productId;
    private UUID organizationId;

    private DeviceStatus(long ts, DeviceStatusEnum status, UUID deviceId, UUID productId, UUID organizationId) {
        this.ts = ts;
        this.status = status;
        this.deviceId = deviceId;
        this.productId = productId;
        this.organizationId = organizationId;
    }

    public static DeviceStatus create(long ts, DeviceStatusEnum status, UUID deviceId, UUID productId, UUID organizationId) {
        return new DeviceStatus(ts, status, deviceId, productId, organizationId);
    }

    public String getDeviceIdStr() {
        return UUIDToString(deviceId);
    }

    public String getProductIdStr() {
        return UUIDToString(productId);
    }

    public String getOrganizationIdStr() {
        return UUIDToString(organizationId);
    }

    private String UUIDToString(UUID uuid) {
        return uuid.toString().replace("-", "_");
    }
}
